import ajax from "./ajax";
import axios from "axios";
export const reqLogin = (username, password) =>
  ajax("/login", { username, password }, "POST");

export const reqGetCategory = (parentId) =>
  ajax("/manage/category/list", { parentId });

export const reqChangeCategory = (categoryId, categoryName) =>
  ajax("/manage/category/update", { categoryId, categoryName }, "POST");

export const reqAddCategory = (parentId, categoryName) =>
  ajax("/manage/category/add", { parentId, categoryName }, "POST");

export const reqGetProduct = (
  { pageNum, pageSize },
  productName,
  productDesc
) =>
  ajax("/manage/product/search", {
    pageNum,
    pageSize,
    productName,
    productDesc,
  });

export const reqRemoveProduct = (productId, status) =>
  ajax("/manage/product/updateStatus", { productId, status }, "POST");

//获取用户列表
export const reqUserList = () => ajax("/manage/user/list");
export const reqClimate = () => {
  return axios("https://api.help.bj.cn/apis/weather/?id=101070201");
};
export const reqAddUser = (user) => ajax("/manage/user/add", user, "POST");
export const reqDelUser = (userId) =>
  ajax("/manage/user/delete", { userId }, "POST");

export const reqUpdateUser = (user) =>
  ajax("/manage/user/update", user, "POST");
export const reqRoleList = () => ajax("/manage/role/list");
export const reqSetRole = (role) => ajax("/manage/role/update", role, "POST");
export const reqDelPic = (name) => ajax("/manage/img/delete", name, "POST");
